package chapter13;

import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author : DuJiabao
 * @Date : 2021/2/24 17:03
 * @Project : thinking_in_java
 * @File : null.java
 * @Desc :
 */
public class replaceTest {
  @Test
  public void test() {
    String s = "agfkrjqekrhkfjfkjfkfhjfnfnvfjalkjdfklflwuirhnvn";
    Matcher m = Pattern.compile("[aeoui]").matcher(s);
    StringBuilder sbud= new StringBuilder();
    while (m.find()) {
      m.appendReplacement(sbud, m.group().toUpperCase());
    }
    System.out.println(sbud);  // AgfkrjqEkrhkfjfkjfkfhjfnfnvfjAlkjdfklflwUI
    m.appendTail(sbud); // AgfkrjqEkrhkfjfkjfkfhjfnfnvfjAlkjdfklflwUIrhnvn
    System.out.println(sbud);
  }
}
